package algorithm.dynamic;

public class HanNuoTa {
    public static void doTowers(int topN, char from, char inter, char to) {
        if (topN == 1) {
            // 只有一个的时候，直接从from 移动到 to
            System.out.println("Disk 1 from " + from + " to " + to);
        } else {
            // 1.把顶部的前topN-1 移动到inter
            doTowers(topN - 1, from, to, inter);
            // 2.把最底一个移动到to
            doTowers(1, from, to, inter);
            // System.out.println("Disk " +  topN + " from " + from + " to " + to);
            // 3.把inter中的topN - 1个移动到to
            doTowers(topN - 1, inter, from, to);
        }
    }

    public static void main(String[] args) {
        doTowers(3, 'A', 'B', 'C');
    }
}
